# Maintainer: Felix Yan <felixonmars@archlinux.org>
# Maintainer: Daniel M. Capella <polyzen@archlinux.org>

pkgname=('python-jsbeautifier' 'python-cssbeautifier')
pkgbase=python-jsbeautifier
pkgver=1.14.11
pkgrel=1
arch=('any')
license=('MIT')
url='https://github.com/beautify-web/js-beautify'
depends=('python-editorconfig' 'python-six')
makedepends=(
  'git'
  'python-build'
  'python-installer'
  'python-setuptools'
  'python-wheel'
)
source=("git+$url.git#tag=v$pkgver")
b2sums=('SKIP')

prepare() {
  cd js-beautify
  cp -a python python-css
}

build() {
  cd js-beautify/python
  mv setup-js.py setup.py
  python -m build --wheel --skip-dependency-check --no-isolation
  cd ../python-css
  mv setup-css.py setup.py
  python -m build --wheel --skip-dependency-check --no-isolation
}

check() {
  cd js-beautify
  python python/js-beautify-test.py
}

package_python-jsbeautifier() {
  pkgdesc='JavaScript unobfuscator and beautifier'
  cd js-beautify/python
  python -m installer --destdir="$pkgdir" dist/*.whl
  install -D -m644 -t "$pkgdir"/usr/share/licenses/"${pkgname[0]}" ../LICENSE
}

package_python-cssbeautifier() {
  pkgdesc='CSS unobfuscator and beautifier'
  depends+=('python-jsbeautifier')
  cd js-beautify/python-css
  python -m installer --destdir="$pkgdir" dist/*.whl
  install -D -m644 -t "$pkgdir"/usr/share/licenses/"${pkgname[1]}" ../LICENSE
}
